Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

native-or-another

Package Overview
Dependencies
Maintainers
1
Versions
8
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

native-or-another

Always will expose native `Promise` if available, otherwise `Bluebird` but only if you don't give another promise module like `q` or `promise` or what you want.

  • 3.0.2
  • Source
  • npm
  • Socket score

Version published
Weekly downloads
3.3K
decreased by-11.17%
Maintainers
1
Weekly downloads
 
Created
Source

native-or-another npmjs.com The MIT License

Always will expose native Promise if available, otherwise Bluebird but only if you don't give another promise module like q or promise or what you want.

Heads up: v3 is here! See the changelog.md

code climate standard code style travis build status coverage status dependency status

Install

npm i native-or-another --save

Usage

For more use-cases see the tests

const getPromise = require('native-or-another')

nativeOrAnother

Always will expose native Promise if available. Otherwise given promise module or Bluebird.

  • [Prome] {Function} custom promise module
  • returns {Function} native Promise or another

Example

const fs = require('fs')
const NativeOrBluebird = getPromise()
const NativeOrPromise = getPromise(require('promise'))
const NativeOrPinkie = getPromise(require('pinkie'))
const NativeOrQ = getPromise(require('q'))

const promise = new NativeOrBluebird((resolve, reject) => {
  fs.readFile('package.json', 'utf-8', (err, res) => {
    if (err) return reject(err)
    resolve(res)
  })
})

promise.then(data => {
  console.log(JSON.parse(data).name)
  //=> 'native-or-another'
})
  • always-done: Handles completion and errors of anything!
  • always-promise: Promisify basically everything.
  • always-thunk: Create thunk from anything, works like thunkify. Transforms anything (callbacks, streams, promises, observables, child processes, sync and generator functions) to thunk.
  • redolent: Simple promisify a callback-style function with sane defaults.

Contributing

Pull requests and stars are always welcome. For bugs and feature requests, please create an issue.
But before doing anything, please read the CONTRIBUTING.md guidelines.

Charlike Make Reagent new message to charlike freenode #charlike

tunnckocore.tk keybase tunnckoCore tunnckoCore npm tunnckoCore twitter tunnckoCore github

Keywords

FAQs

Package last updated on 13 Jan 2016

Did you know?

Socket

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc